class Solution {
public:
    long long minimumTime(vector<int>& time, int totalTrips)
    {
        int min = *min_element(time.begin(), time.end());
        long long l = 1, r = 1LL * min * totalTrips;
        while (l < r)
        {
            long long cnt = 0;
            long long mid = (l + r) >> 1;
            for (auto a : time) cnt += mid / a;
            if (cnt >= totalTrips) r = mid;
            else l = mid + 1;
        }
        return l;
    }
};